<template>
  <van-nav-bar
    title="用户中心"
    left-text="返回"
    left-arrow
    @click-left="$router.back()"
  />
  <van-cell-group inset>
    <van-field
      v-model="sms"
      center
      clearable
      label="短信验证码"
      placeholder="请输入短信验证码"
    >
      <template #button>
        <van-button size="small" type="danger">发送验证码</van-button>
      </template>
    </van-field>
  </van-cell-group>
  <van-button @click="submit" :disabled="sms.length !== 6" round type="danger"
    >下一步</van-button
  >
</template>

<script setup lang="ts">
import { ref } from "vue";
import type { Ref } from "vue";
import { useRoute } from "vue-router";
import { msgCode } from "@/api/api";

const sms: Ref<string> = ref("");
const route = useRoute();

const submit = async () => {
  console.log(route.query.tel);
  const res = await msgCode({ tel: route.query.tel as string });
  console.log(res);
};
</script>

<style></style>
